using UnityEngine;
using UnityEngine.UI;

public class UXImageTestScript : MonoBehaviour
{
    [SerializeField]
    private UXImage testImage;

    [SerializeField]
    private Button[] languageButtons;

    void Start()
    {
        // 设置测试图片的资源文件夹路径
        if (testImage != null)
        {
            testImage.spriteFolderPath = "UX_Samples/LocalizationSample/TestNewStructure";
            testImage.ignoreLocalization = false;
            testImage.IsHotMode = false; // 测试非热更模式
        }

        // 设置语言切换按钮
        for (int i = 0; i < languageButtons.Length; i++)
        {
            int languageIndex = i;
            languageButtons[i].onClick.AddListener(() =>
            {
                LocalizationHelper.SetLanguage((LocalizationHelper.LanguageType)languageIndex);
                Debug.Log($"切换到语言: {(LocalizationHelper.LanguageType)languageIndex}");
            });
        }
    }

    void Update()
    {
        // 按数字键1-4切换语言进行测试
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            LocalizationHelper.SetLanguage(LocalizationHelper.LanguageType.Chinese_Simplified);
            Debug.Log("切换到中文");
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            LocalizationHelper.SetLanguage(LocalizationHelper.LanguageType.Chinese_Traditional);
            Debug.Log("切换到繁体中文");
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            LocalizationHelper.SetLanguage(LocalizationHelper.LanguageType.English);
            Debug.Log("切换到英文");
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            LocalizationHelper.SetLanguage(LocalizationHelper.LanguageType.Japanese);
            Debug.Log("切换到日文");
        }
    }
}
